﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WenSkin.Controls
{
    public class WenTabHeader : WenControl
    {
        public WenTabHeader() : base()
        {
            Height = 25;
        }

        #region 私有属性

        private ListTabPage pages;

        #endregion

        #region 公有属性

        [Category("Wen"), Description("尺寸大小"), DefaultValue(typeof(Size), "300,25")]
        public new Size Size { get => base.Size; set => base.Size = value; }

        #endregion

        #region 子类 标签页面
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ListTabPage Pages => pages ??= new ListTabPage(this);
        public class ListTabPage : List<TabPage>
        {
            private WenTabHeader owner;
            public ListTabPage(WenTabHeader owner)
            {
                this.owner = owner;
            }
        }

        public class TabPage
        {
            public string Text { get; set; }
            public int Width { get; set; }



        }

        #endregion

        #region 重绘

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics.SetGDIHigh();

            RectangleF rec = new RectangleF(0, 0, 0, 0);
            //画图形
            foreach (var item in Pages)
            {
                rec = new RectangleF(rec.X + rec.Width + 2, 0, item.Width, this.Height);

                g.DrawString(item.Text, this.Font, new SolidBrush(this.ForeColor), rec, ControlHelper.StringConters);
            }

        }




        #endregion

    }
}